<?php

namespace MyApp\Hook;

use RedBean_Facade as R;

class App
{
    public static function afterDispatch()
    {
        $app = \Slim\Slim::getInstance();
        $route = $app->router()->getCurrentRoute();
        if ($app->request->isAjax()) {
            die('{"gameover":1}');
        }
        // 02.18游戏结束
        $routeName = $route->getName();
        if (!in_array($routeName, ['gameover', 'count', 'export']) && intval(date('md')) > 218) {
            $app->redirect($app->urlFor('gameover'));
        }
    }
}